import Vue from 'vue'
import Vuex from 'vuex'
import api from "../api"

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        isLogin:false,   //判断是否登录
        token:"",
        user:{}  //用户信息
    },
    mutations: {
        updateIsLogin(state,value){
            state.isLogin = value;
        },
        updateToken(state,value){
            state.token = value;
            localStorage.setItem('token',state.token) //数据持久化
        },
        updateUser(state,value){
            state.user = value;
        }
    },
    actions: {
        getLogin(context,value){
            // let res = await getPhoneLogin(value);
            // console.log(res);
            api.getPhoneLogin(value).then(res =>{
                // console.log(res);
                return res;
            })
        }
    }
})